/*
 * FibBoot.java
 *
 * Created on May 29, 2005, 4:17 PM
 */

package aa.application.Fibonacci;

/**
 *
 * @author  xinghuizhao
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import aa.core.*;
import aa.gui.View;

/**
 *
 * @author  xinghuizhao
 */
public class BootFib {
    
    /** Creates a new instance of BootFib */
    public BootFib() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        
        Integer myPort = new Integer(8070);
        
        //View myView = new View(myPort);
        
        Platform pPlatform=new Platform(null,myPort);
        
        pPlatform.start();
        
        Object[] nullobja={};
        
        CyberOrg fibCyber=(CyberOrg)pPlatform.createCyberOrg(new Long(90000000), new Long(900000), new Long(1000),"aa.core.FacilitatorActor", nullobja);
        
        ActorName facility=fibCyber.getFacilitator();
        
        ActorName fibonacciActor=null;
        
        //try{
            fibonacciActor=pPlatform.createActor(facility, "aa.application.Fibonacci.FibActor", nullobja);
        //}catch(CreateActorException e){
            
        //}
            
        System.out.print("Please input the Fibonacci number you want to calculate: ");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String strNum=null;
        try{
        		strNum = br.readLine();
        } catch (IOException ioe){
        		System.out.println("IO error trying to read the Fibonacci number!");
        		System.exit(1);
        }
        
        int fibNum = Integer.parseInt(strNum);
        Object[] Ags=new Object[3];
        Ags[0]=new Integer(fibNum);
        Ags[1]=fibonacciActor;
        Ags[2]="result";
        
        ActorMessage request=new ActorMessage(pPlatform.getActorNameOfPlatform(), 
                                                fibonacciActor, "fib",Ags, false);
        
        pPlatform.sendMessage(request);
        
    }
    
}
